package com.opoc.controller;

import com.opoc.pojo.Result;
import com.opoc.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/admin")
public class AdminController {
  @Autowired
  AdminService adminService;

  /**
   *系统管理员登录
   */
  @PostMapping("/login")
  public Result login(@RequestParam("account") String account,
                      @RequestParam("password") String password){

   Map<String, String> data = adminService.login(account, password);
    return data.isEmpty() ? Result.error("账号或密码错误") : Result.success(data);
  }

  /**
   *请求方式测试点
   */
  @GetMapping("/test")
  public Result test(@RequestParam("data") Map<String, String> aaa){
    log.info(aaa.toString());
    return null;
  }

}
